package com.longteng.lesson2.controller;

import com.longteng.lesson2.domain.LoginUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/login")
@SessionAttributes(value = {"loginUser"})
public class LoginController {

    private static String PASSWORD ="abc";

    @RequestMapping("/login")
    public ModelAndView l(LoginUser loginUser){
        ModelAndView modelAndView=new ModelAndView();
        String password =loginUser.getPassword();
        if(!password.equalsIgnoreCase(PASSWORD)){
            modelAndView.addObject("msg","登录密码错误");
            modelAndView.setViewName("/form/view");
        }else {
            modelAndView.addObject("loginUser",loginUser);
            modelAndView.setViewName("success");
        }
        return modelAndView;
    }
}
